Skip to content

fix(spanner): harden and guard sensitive connection properties - #14982

Merged
olavloite merged 2 commits into
mainfrom
spanner-harden-guarded-conn-properties
Nov 16, 2026
Merged

olavloite merged 2 commits into
mainfrom
spanner-harden-guarded-conn-properties

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Harden connection properties that allow dynamic class loading (credentialsProvider, channelProvider, and grpc_interceptor_provider) against premature reflection and unauthorized instantiation.

Previously, properties like credentialsProvider attempted to load classes during connection URI parsing before system property authorization could be checked. This change:

  • Defers all dynamic class loading until after the required system property check has passed.
  • Prevents class static initializers from running prematurely during class lookup.
  • Strictly verifies that configured classes are non-abstract, implement the expected interface, and provide a public no-argument constructor.
  • Translates class linkage and static initialization errors into user-friendly invalid argument exceptions.
  • Adds comprehensive test coverage for authorization guards, invalid inputs, and reflection error scenarios.

Harden connection properties that allow dynamic class loading
(`credentialsProvider`, `channelProvider`, and `grpc_interceptor_provider`)
against premature reflection and unauthorized instantiation.

Previously, properties like `credentialsProvider` attempted to load classes
during connection URI parsing before system property authorization could be
checked. This change:

- Defers all dynamic class loading until after the required system property
  check has passed.
- Prevents class static initializers from running prematurely during class
  lookup.
- Strictly verifies that configured classes are non-abstract, implement the
  expected interface, and provide a public no-argument constructor.
- Translates class linkage and static initialization errors into user-friendly
  invalid argument exceptions.
- Adds comprehensive test coverage for authorization guards, invalid inputs,
  and reflection error scenarios.
@olavloite
olavloite requested review from a team as code owners November 12, 2026 09:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the client-side statement value converters in the Spanner connection API by introducing a common abstract base class GuardedClassConverter. This base class consolidates the dynamic class loading, validation, and instantiation logic for CredentialsProvider, GrpcInterceptorProvider, and ExternalChannelProvider. Additionally, ConnectionOptions has been updated to use these converters, and ConnectionProperties now defines CREDENTIALS_PROVIDER as a String property. Comprehensive unit tests have been added to verify various edge cases, such as missing no-arg constructors, abstract classes, and class-loading failures. There are no review comments, so no further feedback is provided.

@olavloite
olavloite merged commit 338485a into main Nov 16, 2026
204 checks passed
@olavloite
olavloite deleted the spanner-harden-guarded-conn-properties branch November 16, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants